#-*-coding:utf-8-*-
'''
Created on 2012-6-3
C:/Users/zhaoyh/workspace/yfmis/addons/PF/formdesigner/controller.py
@author: zhaoyh
'''
import web
from config import render_mako
from addons.portal.company.model import Company,init,update
from db.meta import getsession
from utils.utility import AppStatus
view=render_mako(directories=['templates/PF/formdesigner'],input_encoding='utf-8')
class Main():
    def GET(self):
            return view.formdesigner_main()
    def POST(self):
        u=web.input(order=[],db_code=[],desc=[],Default=[],
                    length=[],type=[],validate=[],
                    is_required=[],is_edit=[],is_list=[],
                    dismode=[],minlength=[],maxlength=[],is_code=[],
                    is_name=[],is_pcode=[],is_Quote=[])
        html=''
        form_html=[]
        print u
        for x in range(len(u.order)):
            
            t_order=u.order.pop()
            t_db_code=u.db_code.pop()
            t_desc=u.desc.pop()
            t_Default=u.Default.pop()
            t_length=u.length.pop()
            t_type=u.type.pop()
            t_validate=u.validate.pop()
            t_is_required=u.is_required.pop()
            t_is_edit=u.is_edit.pop()
            t_is_list=u.is_list.pop()
            t_dismode=u.dismode.pop()
            t_minlength=u.minlength.pop()
            t_maxlength=u.maxlength.pop()
            t_is_code=u.is_code.pop()
            t_is_name=u.is_name.pop()
            t_is_pcode=u.is_pcode.pop()
            t_is_Quote=u.is_Quote.pop()
            if t_is_edit=="true":
                
                if t_type=="text":               
                    form_html[t_order]='<p><label>%s：</label>  <input type="text" name="%s" class="%s %s" %s="true"/> </p>' %(t_desc,t_db_code,t_is_required,t_validate,t_dismode)
                    

                elif t_type=="textarea":
                    print   '<textarea  name="%s" class="%s %s" type="%s" size="30" value="${co.co_website}" />' %u.db_code.pop(),u.is_required.pop(),u.validate.pop()
                elif t_type=="combox":
                    pass
                elif t_type=="radio":
                    pass
                elif t_type=="Suggest":
                    pass
                elif t_type=="lookup_tree":
                    pass
                elif t_type=="lookup_list":
                    pass
                elif types=="select":
                    pass
                elif types=="Invisible":
                    pass
        print form_html


class types():
    def POST(self):
            return view.type()
class validate():
    

         
         return view.validate()
class enum():
    """主从枚举"""
    def POST(self,name):
        return view.enum(name=name)      
class select():
    """选择项注意联动"""
    def POST(self,name):
        return view.enum(name=name)
class lookup_list ():
    """选择项"""
    def POST(self,name):
        return view.enum(name=name)
class lookup_tree ():
    """选择项"""
    def POST(self,name):
        return view.enum(name=name)
class suggest ():
    """选择项"""
    def POST(self,name):
        return view.enum(name=name)              